﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Program.cs" company="Scrum for Team System">
//   None
// </copyright>
// <summary>
//   Defines the Program type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Bootstrapper
{
    using System;
    using System.IO;
    using System.Windows.Forms;
    
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            string msiFilename = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), Constants.MsiFilename);
            if ( File.Exists(msiFilename) )
            {
                File.Delete(msiFilename);
            }

            Helpers.ExtractEmbeddedResources(Constants.MsiResourceName, msiFilename);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Main(msiFilename));

#if !DEBUG
            File.Delete(msiFilename);
#else
            MessageBox.Show(string.Format("Extracted MSI has been left behind:{1}{1}'{0}'", msiFilename, Environment.NewLine));
#endif
        }
    }
}
